package edu.gdkm.web.controller;

import edu.gdkm.service.iface.GoodsService;
import edu.gdkm.sql.pojo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/home/goods/")
@CrossOrigin
@ResponseBody
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @RequestMapping("/list")
    public List<Goods> list(Integer category_id, Integer last_id,Integer pagesize) {
        return goodsService.findByCategoryId(category_id, last_id, pagesize);
    }
    @RequestMapping("/detail")
    public Goods detail(Integer id) {
        return goodsService.findById(id);
    }
    @RequestMapping("/cart")
    public List<Goods> cart(Integer[] ids) {
        System.out.println(goodsService.findByIds(ids));
        return goodsService.findByIds(ids);
    }

}
